const cloneObj = obj => {
    let newObj = Array.isArray(obj) ? [] : {}
    for (const key in obj) {
        if (obj[key] && typeof obj[key] === 'object') {
            newObj[key] = cloneObj(obj[key])
        } else {
            newObj[key] = obj[key]
        }
    }
    return newObj
}
const obj = {
    name: 'jack',
    age: 23,
    phone: {
        tel: 13454323445,
    },
    say() {
        console.log(this.phone.tel)
    },
}
debugger
// const newObj = {...obj}
const newObj = cloneObj(obj)

newObj.name = 'rose'
newObj.phone.tel = 18888888888
console.log(obj)
console.log(newObj)
// console.log(newObj.say() === obj.say())
